home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / evilswitch.swf / scripts / frame_2 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  1.4 KB  |  66 lines

  1. Array.prototype.getItemIndex = function(tItem)
  2. {
  3.    var _loc3_ = this.length;
  4.    var _loc2_ = 0;
  5.    while(_loc2_ < _loc3_)
  6.    {
  7.       if(this[_loc2_] == tItem)
  8.       {
  9.          return _loc2_;
  10.       }
  11.       _loc2_ = _loc2_ + 1;
  12.    }
  13.    return -1;
  14. };
  15. this.goto = function(tStr)
  16. {
  17.    _global.gGameState = tStr;
  18.    this.gotoAndPlay(tStr);
  19. };
  20. this.setKeys = function()
  21. {
  22.    this.keyDetect = new Object();
  23.    this.keyDetect.onKeyDown = function()
  24.    {
  25.       keyPressed(Key.getCode() == 38,Key.getCode() == 40,Key.getCode() == 37,Key.getCode() == 39,Key.getCode() == 32);
  26.    };
  27.    Key.addListener(this.keyDetect);
  28.    this.pKeyDelay = 0;
  29.    this.pKeyActive = true;
  30. };
  31. this.setKeyInt = function()
  32. {
  33. };
  34. this.clearKeyInt = function()
  35. {
  36.    this.pKeyActive = true;
  37.    clearInterval(this.pKeyDelay);
  38. };
  39. this.keyPressed = function(aUp, aDown, aLeft, aRight, aAction)
  40. {
  41.    switch(gGameState)
  42.    {
  43.       case "menu":
  44.          if(aAction)
  45.          {
  46.             this.soul_mc.clearMap();
  47.             this.goto("newGame");
  48.          }
  49.          break;
  50.       case "newGame":
  51.          if(aAction)
  52.          {
  53.             this.goto("game");
  54.          }
  55.          break;
  56.       case "game":
  57.          this.grid_mc.selector_mc.moveSelect(aRight - aLeft,aDown - aUp);
  58.          if(aAction)
  59.          {
  60.             this.grid_mc.selector_mc.pressSelect();
  61.          }
  62.    }
  63. };
  64. this.setKeys();
  65. this.goto("menu");
  66.